window.onload=function(){
	//borwserShow();
}

//置顶
function topDo(){
	$('body,html').animate({scrollTop:0},500);
}
//定位
function locationDo(id){
	$('body,html').animate({scrollTop:$("#"+id).offset().top},500);
}
//定位
function locationNumDo(id,num){
	$('body,html').animate({scrollTop:$("#"+id).offset().top-num},500);
}

//发布需求
function publishWantToBuyLink(){
	window.open("supplyDemandPublishWantToBuy.html");
}
//发布卖品
function publishSellGoodsLink(){
	window.open("supplyDemandPublishSellGoods.html");
}
//搜索
function allWebSearchLink(){
	window.location.href="zbtSearchResult.html";
}

//服务项目
function goodsListLink(obj){
	window.location.href="goodsList.html?item="+$(obj).attr('value');
}

//供求中心搜索
function supplyDemandSearch(obj){
	if (event.keyCode == "13") { 
    	window.location.href="supplyDemandSearchResult.html";
   	}
}
//复选框
function checkboxDo(obj){
	if($(obj).hasClass("on")){
		$(obj).removeClass("on");
		$(obj).attr("isSelect",false);
	}else{
		$(obj).addClass("on");
		$(obj).attr("isSelect",true);
	}
}

//单选
function radioDo(obj){
	$(obj).parent().find(".lable-btn").attr("isSelect",false);
	$(obj).parent().find(".lable-btn").removeClass("on");
	$(obj).attr("isSelect",true);
	$(obj).addClass("on");
}

//第一个字母大写
function firstToUpperCaseDo(str){
	var firstStr=str.substring(0,1).toUpperCase();
	return firstStr+str.substring(1,str.length);
}

//倒计时
var wait=60;
function time(obj) {
	if (wait == 0) {
		$(obj).attr("disabled",false);
		$(obj).removeClass("btn-disabled");
		$(obj).addClass("btn-default");
		$(obj).val("获取验证码");
		wait = 60;
	} else {
		$(obj).attr("disabled",true);
		$(obj).removeClass("btn-default");
		$(obj).addClass("btn-disabled");
		$(obj).val("重新发送(" + wait + ")");
		wait--;
		setTimeout(function(){time($(obj))},1000);
	}
}

//读秒跳转
var second=5;
function tiemSecondDo(obj,linkTxt){
	if (second == -1) {
		window.location.href=linkTxt;
		second = 5;
	} else {
		$(obj).text(second);
		second--;
		setTimeout(function(){tiemSecondDo($(obj),linkTxt)},1000);
	}
}

//获取链接参数
function getLinkString(name){
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null){
     	return  unescape(r[2]);
     }else{
     	return null;
     }
}

//输入数字限制
function numberInputDo(obj){
	obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符
   	obj.value = obj.value.replace(/^\./g,"");  //验证第一个字符是数字而不是.
   	obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的.
   	obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
	if(num=="NaN" || num==null || num==""){
		$(obj).val("0");
	}else{
		$(obj).val(parseFloat(num));
	}
}

//数字加减
function numberCountDo(obj){
	var numberText=$(obj).parent().find(".number-text");
	if($(obj).attr("value")=="-"){
		if(parseInt(numberText.val())-1<=0){
			return;
		}else{
			numberText.val(parseInt(numberText.val())-1);
		}
	}
	if($(obj).attr("value")=="+"){
		numberText.val(parseInt(numberText.val())+1);
	}
}

//maxLen = 100; //定义用户可以输入的最多字数
function checkMaxInput(obj,txt,maxLen) {
	var objTxt=document.getElementById(txt);
	if (obj.value.length >= maxLen){ //如果输入的字数超过了限制
		obj.value = obj.value.substring(0, maxLen); //就去掉多余的字
		objTxt.innerText = (obj.value.length)+"/"+maxLen+" 内容超出了字数限制";
		objTxt.style.color="#f00";
	}
	else{
		objTxt.innerText = (obj.value.length)+"/"+maxLen;//计算并显示剩余字数
		objTxt.style.color="#999";
	}
}

//删除图片
function imgDelDo(obj){
	$(obj).parent().remove();
}

//返回
function goBackDo(){
	window.history.go(-1);
}

//文本截取
function textCutOutDo(txt,num){
	if(txt.length >= num){
		return txt.substr(0,num) + '...';
	}
}

function borwserShow(){
	var borwserPrompt="<div id='browserVerMask' class='browser-ver-mask'></div>"+
	"<div id='browserVer' class='browser-ver radius5'>"+
		"<h3 class='browser-ver-title'>您使用的浏览器版本过低，可能有安全风险</h3>"+
		"<div class='browser-ver-title'>推荐使用一下浏览器</div>"+
		"<div class='browser-ver-list'>"+
			"<a class='border-box' target='_blank' href='https://www.baidu.com/s?ie=utf-8&wd=chrome&oq=chrome'>"+
				"<img class='icon-logo' src='images/browser/chrome-logo.png' />"+
				"<span>谷歌浏览器</span>"+
				"<input type='button' value='下载' class='zbtui-btn zbtui-btn-mini' />"+
			"</a>"+
			"<a class='border-box' target='_blank' href='https://www.baidu.com/s?ie=utf-8&wd=Firefox&oq=Firefox'>"+
				"<img class='icon-logo' src='images/browser/firefox-logo.png' />"+
				"<span>火狐浏览器</span>"+
				"<input type='button' value='下载' class='zbtui-btn zbtui-btn-mini' />"+
			"</a>"+
			"<a class='border-box' target='_blank' href='http://browser.qq.com/'>"+
				"<img class='icon-logo' src='images/browser/qq_logo.png' />"+
				"<span>QQ浏览器</span>"+
				"<input type='button' value='下载' class='zbtui-btn zbtui-btn-mini' />"+
			"</a>"+
			"<a class='border-box' target='_blank' href='http://se.360.cn/'>"+
				"<img class='icon-logo' src='images/browser/360-logo.png' />"+
				"<span>360浏览器</span>"+
				"<input type='button' value='下载' class='zbtui-btn zbtui-btn-mini' />"+
			"</a>"+
			"<div class='clra'></div>"+
		"</div>"+
		"<div class='browser-ver-title mtop'>或使用浏览器极速模式</div>"+
		"<div class='browser-ver-content'>360、遨游、猎豹、QQ等浏览器【<a class='fc-link' target='_blank' href='https://jingyan.baidu.com/article/22a299b539f4b19e18376a5b.html'>极速模式</a>】切换帮助</div>"+
	"</div>";
	
	if(browserVersion()=="IE6" || browserVersion()=="IE7" || browserVersion()=="IE8"){
		var divObj=document.createElement("div");
		divObj.innerHTML=borwserPrompt;
		document.body.appendChild(divObj);
		
		document.getElementById("browserVerMask").style.display="block";
		document.getElementById("browserVer").style.display="block";
	}
}

//浏览器判断
function browserVersion(){
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=b_version.split(";"); 
	var trim_Version=version[1].replace(/[ ]/g,"");
	if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") 
	{ 
		return "IE6"; 
	} 
	else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") 
	{ 
		return "IE7"; 
	} 
	else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE8.0") 
	{ 
		return "IE8";
	} 
	else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE9.0") 
	{ 
		return "IE9";
	}
	
	var userAgent = navigator.userAgent;
	if (userAgent.indexOf("Opera") > -1){
		return "Opera"
	}
	if (userAgent.indexOf("Firefox") > -1) {
         return "FF";
	}
	if (userAgent.indexOf("Chrome") > -1){
		return "Chrome";
	}
	if(userAgent.indexOf("Safari") > -1) {
		return "Safari";
	}
}